#include <glib.h>

gint global_count = 0;
static gpointer _thread_func(gpointer data)
{
    gint i = 0;
    gpointer retval = NULL;

    for(i=0;i<10000;i++) {
        global_count += i;
    }
    g_print("count:%d \n", global_count);
}

void test_thread_join(void)
{
    GThread *th1,*th2,*th3;
    th1 = g_thread_new("th1", _thread_func, NULL);
    th2 = g_thread_new("th2", _thread_func, NULL);
    th3 = g_thread_new("th3", _thread_func, NULL);
    g_thread_join(th1);
    g_thread_join(th2);
    g_thread_join(th3);
}

gint main(gint argc, gchar **argv)
{
    g_test_init(&argc, &argv, NULL);

    g_test_add_func("/thread/join", test_thread_join);

    return g_test_run();
}